package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Category;
import com.itheima.reggie.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/category")
@Slf4j
public class CategoryController {
    @Autowired
    private CategoryService categoryService;
    @PostMapping
    public R<String> save(@RequestBody Category category)
    {
      return categoryService.mySave(category);
    }
    @GetMapping("/page")
    public R<Page>page(int page,int pageSize)
    {
       return categoryService.page(page,pageSize);
    }
    @DeleteMapping
    public R<String>delete(Long ids)
    {
       return categoryService.delete(ids);
    }
    @PutMapping
    public R<String>update(@RequestBody Category category)
    {
       return categoryService.update(category);
    }
    @GetMapping("/list")
    public R<List<Category>>list(Category category)
    {
       return categoryService.list(category);
    }
}
